package ExtraTest;

import java.util.Random;
import java.util.Scanner;

/**
 * @author 刘全
 * @date 2021/7/25
 */
public class ChouJiang {
    public static void main(String[] args) {
        //某游戏的抽奖概率为0.6%,并且每当抽90次必定抽中,抽中时重置保底
        Random r = new Random();
        int count = 0, result = 0;
        Scanner sc = new Scanner(System.in);
        System.out.println("当前剩余抽奖次数为:");
        int sum = sc.nextInt();
        int choice;
        while (sum > 0) {
            while (true) {
                System.out.println("请选择抽1次或10连抽:");
                choice = sc.nextInt();
                if (sum == 0) {
                    if (choice == 1 || choice == 10) {
                        System.out.println("您的次数不足!");
                        break;
                    } else {
                        System.out.println("输入有误,请重新输入");
                        continue;
                    }
                } else if (sum > 0 && sum < 10) {
                    if (choice == 10) {
                        System.out.println("您的次数不足,请重新输入!");
                        continue;
                    } else if (choice == 1) {
                        break;
                    } else {
                        System.out.println("输入有误,请重新输入");
                        continue;
                    }
                } else {
                    if (choice == 1 || choice == 10) {
                        break;
                    } else {
                        System.out.println("输入有误,请重新输入");
                        continue;
                    }
                }
            }
            //for (int i = 0; i < choice;
            //计算抽奖概率
            int num = r.nextInt(1000) + 1;
            result++;
            if (count != 90) {
                count++;
            }
            System.out.println(num);
            if (num >= 498 && num <= 503 && count != 90) {
                count = 0;
                System.out.println("你已经抽了:" + result + "次");
                System.out.println("----------金色传说!---------");
            } else if (count == 90) {
                count = 0;
                System.out.println("你已经抽了:" + result + "次");
                System.out.println("你保底了!");
                System.out.println("----------金色传说!---------");
            } else {
                System.out.println("你已经抽了:" + result + "次");
                System.out.println("很遗憾,你没有中奖");
            }
        }
        //sum -= choice;
        System.out.println("您还剩" + sum + "次抽奖机会");
    }
}

